// pages/grzy/grzy.js
//获取应用实例
const app = getApp()
//储存移动的位置
let touchMove = []
import Time from "../../utils/time"
let Player = require("../../utils/player"),
    audioList = [],
    player = new Player(),
    playerCurrent = {},
    videoContext = {}
const api = require('../../utils/interface.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    whose: ["/images/duola2.png", "/images/duola2.png"],
    bq: ["女神", "宝妈"],
    log: [
        {
        avatar: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
        sex: true, // true 男 false 女
        name: "ahhhh",
        startDate: '2',
        dateNumber: '20',
        // 文字 图片 声音 视频
        content: {
          character: '今天天气很好 我很开心',
          photo: [
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg"
          ],
          audio: "",
          movie: "",
          // 参与打卡 图片 名字 加入人数
          joinRole: {
            photo: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            name: '英语早操',
            joinNumbr: '1024'
          }
        },
        // 互动 关注 红心 评论
        interaction:
            {
          isAttention: true,
          isHeart: false,
          heartNumber: ["A", "B", "C"],
          // 评论内容
          comment: [],
          // 是否缩进
          isComment: false
        }
      },
      {
        avatar: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
        sex: false, // false 男 true 女
        name: "ahhhh",
        startDate: '2',
        dateNumber: '20',
        // 文字 图片 声音 视频
        content: {
          character: '今天天气很好 我很开心',
          photo: [
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            // "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            // "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg"

          ],
          audio: "",
          movie: "",
          // 参与打卡 图片 名字 加入人数
          joinRole: {
            photo: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            name: '英语早操',
            joinNumbr: '1024'
          }
        },
        // 互动 关注 红心 评论
        interaction: {
          isAttention: false,
          isHeart: false,
          heartNumber: ["A", "B", "C"],
          // 评论内容
          comment: [],
          // 是否缩进
          isComment: false
        }
      },
      {
        avatar: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
        sex: false, // false 男 true 女
        name: "ahhhh",
        startDate: '2',
        dateNumber: '20',
        // 文字 图片 声音 视频
        content: {
          character: '今天天气很好 我很开心',
          photo: [
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            // "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            // "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg"

          ],
          audio: {
            url: "http://ip.h5.rc01.sycdn.kuwo.cn/resource/n3/96/56/2310568805.mp3",
            startDate: '00:00',
            endDate: '03:00'
          },
          movie: "",
          // 参与打卡 图片 名字 加入人数
          joinRole: {
            photo: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            name: '英语早操',
            joinNumbr: '1024'
          }
        },
        // 互动 关注 红心 评论
        interaction: {
          isAttention: false,
          isHeart: true,
          heartNumber: ["A", "B", "C"],
          // 评论内容
          comment: [],
          // 是否缩进
          isComment: false
        }
      },
      {
        avatar: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
        sex: false, // false 男 true 女
        name: "ahhhh",
        startDate: '2',
        dateNumber: '20',
        // 文字 图片 声音 视频
        content: {
          character: '今天天气很好 我很开心',
          photo: [
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
          ],
          audio: {
            url: "http://ar.h5.ra01.sycdn.kuwo.cn/resource/n2/320/21/79/2129722879.mp3",
            startDate: '00:00',
            endDate: '03:00'
          },
          movie: "",
          // 参与打卡 图片 名字 加入人数
          joinRole: {
            photo: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528128688402&di=0ab35793c7e297479e56ff841b08b7af&imgtype=0&src=http%3A%2F%2Fp5.yokacdn.com%2Fpic%2Fcr%2F2014%2F0821%2F1286020305.jpg",
            name: '英语早操',
            joinNumbr: '1024'
          }
        },
        // 互动 关注 红心 评论
        interaction: {
          isAttention: false,
          isHeart: false,
          heartNumber: ["A", "B", "C"],
          // 评论内容
          comment: [],
          // 是否缩进
          isComment: false
        }
      },

    ],
    //    效果控制
    control: {
      audio: {
        player: {},
        id: "",
        isPlayer: true,
        isPause: false,
        startDate: '00:00',
        progress: "",
        activeProgress: {},
        aniProgress: {},
        loadSucc: false
      },
      movie: {}
    },
    logs: [],
    page: 1,
    size: 10,
    isload: false,
    pkid: 0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
      console.log(options)
    var that=this;
    this.setData({
      pkid: options.id
    });
      console.log(app.globalData.userInfo);
      var that = this;
      that.setData({
          jizhu: app.globalData.userInfo
      });
    this.get_user_info();

    app.Post(api.wxapp.view_me_add, {
      accountId: that.data.pkid
    }, function() {})
  },
  //获取用户信息
  get_user_info: function() {
    var that = this;
    app.Post(api.wxapp.personal_data, {
      accountId: that.data.pkid
    }, function(res) {
      if (res.code == 1) {
        that.setData({
          userInfo: res.data
        });
      } else {
        app.WxAlert(res.msg);
      }
    });
  },
  //获取日记列表
  get_log_list: function() {
    var that = this;
    app.Post(api.wxapp.clock_detail_list, {
      page: that.data.page,
      size: that.data.size,
      accountId: that.data.pkid
    }, function(res) {
      if (res.code == 1) {
        that.setData({
          logs: that.data.logs.concat(res.data.ClockDetailList)
        });
        that.initAudio();
        that.AudioProgress();
        if (res.data.ClockDetailList.length < that.data.size) {
          that.setData({
            isload: true
          });
        } else {
          that.setData({
            page: that.data.page + 1
          });
        }
      }
    });
  },
  bindpraise:function(e){
    let that = this,
      log = that.data.logs,
      bind = e.currentTarget.dataset.bind,
      isHeart = log[bind].IsThumbUp,
      userINfo = that.data.userInfo;
    var param = {
      detailId: e.currentTarget.dataset.id,
      type: isHeart ? 2 : 1
    };
    wx.showLoading({});
    app.Post(api.wxapp.clock_detail_thumb, param, function (res) {
      wx.hideLoading();
      if (res.code == 1) {
        if (!isHeart) {
          log[bind].ThumbsUpList.push({
            AccountId: app.globalData.userInfo.Id,
            Nickname: app.globalData.userInfo.Nickname
          });
          log[bind].IsThumbUp = true
          log[bind].ThumbsUpCount = log[bind].ThumbsUpCount + 1;
        } else {
          var thums = [];
          log[bind].IsThumbUp = false
          log[bind].ThumbsUpCount = log[bind].ThumbsUpCount - 1;
          for (var i = 0; i < log[bind].ThumbsUpList.length; i++) {
            if (log[bind].ThumbsUpList[i].AccountId != app.globalData.userInfo.Id) {
              thums.push(log[bind].ThumbsUpList[i]);
            }
          }
          log[bind].ThumbsUpList = thums;
        }
        that.setData({
          logs: log
        });
      }
    })
  },
  discuss: function (e) {
    wx.navigateTo({
      url: '../discuss/discuss?id=' + e.currentTarget.dataset.id + "&accid=" + e.currentTarget.dataset.accid
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    if (this.data.isShuaXing==false)
    {
      this.setData({
        isShuaXing:true
      })
      return false;
    }
    this.setData({
      logs: [],
      page: 1,
      isload: false,});
    this.get_log_list();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },
  //点击关注
  touchguanZhu: function (e) {
    console.log(e);
    let that = this,
      bind = e.currentTarget.dataset.bind,
      isthumbe = e.currentTarget.dataset.isthumbe,
      accountid = e.currentTarget.dataset.accountid;
    var logs=[];
    //添加关注
    if (!e.currentTarget.dataset.isthumbe) {
      app.Post(api.wxapp.follow_add, {
        accountId: accountid
      }, function (res) {
        if (res.code == 1) {
          app.ShowMsg("关注成功");
          for (var i = 0; i < that.data.logs.length; i++) {
            if (accountid == that.data.logs[i].AccountId) {
              that.data.logs[i].IsFollowd = true;
            }
            logs.push(that.data.logs[i]);
          }
          that.setData({ logs: logs });
        } else {
          app.WxAlert(res.msg);
        }
      });
    } else {
      //取消关注
      app.Post(api.wxapp.follow_delete, {
        accountId: accountid
      }, function (res) {
        if (res.code == 1) {
          app.ShowMsg("取消成功");
          for (var i = 0; i < that.data.logs.length; i++) {
            if (accountid == that.data.logs[i].AccountId) {
              that.data.logs[i].IsFollowd = false;
            }
            logs.push(that.data.logs[i]);
          }
          that.setData({ logs: logs });
        } else {
          app.WxAlert(res.msg);
        }
      });
    }
  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    if (!this.data.isload) {
      this.get_log_list();
    }
  },

  bindwdgz:function(){
      wx.navigateTo({
        url: '../wdgz/wdgz?id=' + this.data.userInfo.Id +"&own=1"
      });
  },
  bindwdfs:function(){
    wx.navigateTo({
      url: '../wdfs/wdfs?id=' + this.data.userInfo.Id + "&own=1"
    });
  },
  imgYu: function (event) {
    var src = event.currentTarget.dataset.src;//获取data-src
    var imgList = event.currentTarget.dataset.list;//获取data-list
    //图片预览
    wx.previewImage({
      current: src, // 当前显示图片的http链接
      urls: imgList // 需要预览的图片http链接列表
    })
    this.setData({
      isShuaXing: false
    })

  },
    // 初始化录音
    initAudio: function () {
        const that = this,
            logs = that.data.logs;
        player.list.clear()
        let audioData = []
        console.log(player.list)
        audioList = []
        for (let i = 0; i < logs.length; i++) {
            if (logs[i].ContentRadio != "") {
                audioList.push({
                    id: "aa",
                    dataUrl: logs[i].ContentRadio,
                    title: i,
                    index: i,
                })
            }
        }
        console.log(audioList)
        player.list.create(audioList)
        console.log(player.list.info())

    },
    //    录音播放实例
    createAudioPlay: function (e) {
        const that = this,
            control = that.data.control,
            time = new Time(),
            isPlayer = control.audio.isPlayer,
            url = e.currentTarget.dataset.bind
        let index;
        for (let j = 0; j < audioList.length; j++) {
            if (audioList[j].index == url) {
                console.log(audioList[j])
                index = audioList[j]._id
            }
        }
        console.log(":-------------------")
        console.log(player.list.info())
        control.audio.id = url
        console.log(index)
        player.list.syncIndex(audioList[index])
        console.log(player.list.current())

        console.log("别的")
        console.log(player.list.current())
        //      判断是否点击当前录音
        if (player.list.current() != null && playerCurrent.index != url) {
            player.stop()
            //    初始化进度条    点击别的录音
            that.audioProgressAnimation(0, control.audio.progress, "00:00")
            // 全部停止

            console.log("开始播放别的-----------")
            setTimeout(function () {
                player.invoke(index)
            }, 100)
            control.audio.isPlayer = false
            that.setData({
                control: control
            })

            player.event.on('timeupdate', function (data) {
                console.log("开始监听")
                if (data.status == 1) {
                    console.log(data)
                    let startDate = time.secondConvertMinute(data.currentPosition)
                    console.log(startDate)
                    let actWidth = parseFloat(data.currentPosition / data.duration)
                    console.log(actWidth)
                    that.audioProgressAnimation(actWidth, control.audio.progress, startDate)
                    if ((data.duration - data.currentPosition) == 0) {
                        console.log("audio end")
                        player.stop()
                        control.audio.isPlayer = true
                        that.setData({
                            control: control
                        })
                        that.audioProgressAnimation(0, control.audio.progress, "00:00")
                    } else {
                        //that.audioProgressAnimation(actWidth, control.audio.progress, startDate)
                    }
                }
            })
        }
        else {
            console.log("点击自己")
            player.event.on('timeupdate', function (data) {
                console.log("开始监听")
                if (data.status == 1) {
                    console.log(data)
                    let startDate = time.secondConvertMinute(data.currentPosition)
                    console.log(startDate)
                    let actWidth = parseFloat(data.currentPosition / data.duration)
                    console.log(actWidth)
                    that.audioProgressAnimation(actWidth, control.audio.progress, startDate)
                    if ((data.duration - data.currentPosition) == 0) {
                        console.log("audio end")
                        player.stop()
                        control.audio.isPlayer = true
                        that.setData({
                            control: control
                        })
                        that.audioProgressAnimation(0, control.audio.progress, "00:00")
                    } else {
                        //that.audioProgressAnimation(actWidth, control.audio.progress, startDate)
                    }
                }
            })

            //点击当当前的录音
            console.log("ahhh")
            // 是否播放
            if (isPlayer) {
                console.log("创建播放")
                if (player.isPaused()) {
                    console.log("继续播放")
                    player.resume()
                }
                else {
                    if (!player.isPlaying()) {
                        console.log("开始播放")
                        player.invoke(index)
                    }
                }
                console.log(player.list.current())
                control.audio.isPlayer = !isPlayer
                that.setData({
                    control: control
                })

            } else {
                if (!player.isPaused()) {
                    player.pause()
                }
                control.audio.isPlayer = !isPlayer
                that.setData({
                    control: control
                })

            }
        }
        playerCurrent = player.list.current()
        console.log(player.list.current())
    },
    //    录音播放进度条
    AudioProgress: function () {
        const that = this,
            control = that.data.control;
        let systemInfo = {}
        wx.getSystemInfo({
            success: res => {
                systemInfo = res
            }
        })
        control.audio.progress = systemInfo.screenWidth * 0.3
        this.setData({
            control: control
        })
    },
    //    录音播放进度条动画
    audioProgressAnimation: function (activeProgress, progresWidth, startDate) {
        const that = this,
            control = that.data.control,
            activePro = wx.createAnimation({}),
            aniPro = wx.createAnimation({}),
            initact = wx.createAnimation({}),
            initani =  wx.createAnimation({})
        //  根据歌曲播放百分比 获取active长度
        const width = progresWidth * activeProgress
        let actWidth = parseFloat(progresWidth - width)
        activePro.width(width * 2).step()
        aniPro.width(actWidth).step()
        initact.width(0).step()
        initani.width(progresWidth).step()

        control.audio.activeProgress = activePro.export()
        control.audio.aniProgress = aniPro.export()
        control.audio.startDate = startDate
        control.audio.initActProgress = initact.export()
        control.audio.initAniProgress = initani.export()
        that.setData({
            control: control
        });
    },
    imgYu: function (event) {
        var src = event.currentTarget.dataset.src; //获取data-src
        var imgList = event.currentTarget.dataset.list; //获取data-list
        //图片预览
        wx.previewImage({
            current: src, // 当前显示图片的http链接
            urls: imgList // 需要预览的图片http链接列表
        })
        this.setData({
            isShuaXing: false
        })

    },
    audioPlay: function () {
        this.setData({
            action: {
                method: 'play'
            }
        });
    },
    videlplay:function(e)
    {
   
        let index = e.currentTarget.dataset.index
        var log = this.data.logs;
        log[index].isMviePlayer=true;
        videoContext = wx.createVideoContext('myVideo' + index)
        videoContext.index = index
        videoContext.requestFullScreen({
            duration:0
        })
        console.log("full")
        this.setData({
          logs:log
        })
    },
    fullVideo:function (e) {
      let log = this.data.logs
        console.log(e)
        console.log(e.detail.fullScreen)
        if(!e.detail.fullScreen){
            videoContext.pause()
            log[videoContext.index].isMviePlayer=false;
            console.log("结束全屏  ")
            this.setData({
              logs:log
            })
        }
    },
    onShareAppMessage: function () {
        return {
            title: '测试分享',
            path: 'pages/index/index'
        }
    },
    whosee: function (e) {
      let that = this;
      console.log(that.data.userInfo)
        wx.navigateTo({
            url: '../whosee/whosee?id=' + this.data.userInfo.Id
        })
        // wx.navigateTo({
        //   url: '../fenxiang/fenxiang?id=' + e.currentTarget.dataset.accid
        // })
    },
    imgLoad:function (e) {
        console.log(e)
        let screen = wx.getSystemInfoSync()

        var width = e.detail.width,
            height = e.detail.height,
            ratio = width/height
        console.log(ratio)
        var viewWidth = screen.screenWidth * 0.5,
            viewHeight = viewWidth / ratio
        let logs = this.data.logs
        logs[e.currentTarget.dataset.bind].img = {
            width:viewWidth,
            height:viewHeight
        }
        console.log(logs)
        this.setData({
            logs:logs
        })
    }
})